# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>
# Contributor: Simon Kohlmeyer <simon.kohlmeyer@gmail.com>

_gemname='minitest'
pkgname="ruby-${_gemname}"
pkgver=5.16.3
pkgrel=1
pkgdesc='Complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking'
url="https://github.com/seattlerb/${_gemname}"
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('rubygems' 'ruby-hoe' 'ruby-rake' 'ruby-rdoc')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('f5ebd3994b42cefc1d0ecb6e18c8b39f41ea60fc5ec22d2cd27e3b09c34aa6085f44a8e096f08aad0c6f72c91cdf4cc22411327b6b3d95aa7a1f3aac459ecbda')

build() {
  cd "${_gemname}-${pkgver}"

  rake gem
}

check() {
  cd "${_gemname}-${pkgver}"

  rake test
}

package() {
  cd "${_gemname}-${pkgver}"

  local _gemdir="$(gem env gemdir)"

  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "${pkgdir}/${_gemdir}" \
    --bindir "${pkgdir}/usr/bin" \
    "pkg/${_gemname}-${pkgver}.gem"

  # remove unrepreducible files
  rm --force --recursive --verbose \
    "${pkgdir}/${_gemdir}/cache/" \
    "${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/vendor/" \
    "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext/"

  find "${pkgdir}/${_gemdir}/gems/" \
    -type f \
    \( \
      -iname "*.o" -o \
      -iname "*.c" -o \
      -iname "*.so" -o \
      -iname "*.time" -o \
      -iname "gem.build_complete" -o \
      -iname "Makefile" \
    \) \
    -delete

  find "${pkgdir}/${_gemdir}/extensions/" \
    -type f \
    \( \
      -iname "mkmf.log" -o \
      -iname "gem_make.out" \
    \) \
    -delete

  install -Dm 644 README.rdoc History.rdoc -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 README.rdoc -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
